﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExpressionPractices.SqlServices
{
    /// <summary>
    /// 最终执行sql方法
    /// </summary>
    public class SqlServices
    {
        private static readonly string SqlConnection = ConfigurationManager.AppSettings["ConnectionString"];

        /// <summary>
        /// 执行sql
        /// </summary>
        public int ExcuteSql(string sql)
        {
            SqlConnection conn = new SqlConnection(SqlConnection);
            SqlCommand comm = new SqlCommand(sql, conn);
            using (comm)
            {
                conn.Open();
                return comm.ExecuteNonQuery();
            }
        }
    }
}
